<template>
	<view class="contents">
		<view class="vtabs">
			<van-tabs active="active" @change="onChange" title-inactive-color='#000' title-active-color='#289958'
				color='#289958'>
				<van-tab title="全部"></van-tab>
				<van-tab title="待核销"></van-tab>
				<van-tab title="已核销"></van-tab>
			</van-tabs>
		</view>
		<view class="oredr_list" v-for="(item,index) in subscribe" :key="index" @click="gotoDetails(item.order_id)">
			<view class="orderno">
				<view class="number">
					<text>单号:{{item.order_id}}</text>
				</view>
				<view class="status">
					{{item.status == 0 ? '待核销':'已核销' }}
				</view>
			</view>
			<view class="reservationnumber">
				<view class="left">
					<image :src="item.image" mode=""></image>
				</view>
				<view class="right">
					<view class="eventname">
						{{item.title}}
					</view>
					<view class="eventaddress">
						<image src="../../static/location1.svg" mode=""></image>
						<text>{{item.province + item.city + item.district +item.detail}}</text>
					</view>
					<view class="eventprice">
						<view class="price">
							￥{{item.pay_price}}
						</view>
						<view class="unumber">
							{{item.upUnmber}}人参加
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="zanwudata" v-if="subscribe.length == 0">
			<view class="">暂无核销数据</view>
		</view>
	</view>
</template>

<script>
	import {
		getActiveList,getOrderDate
	} from '@/api/api.js'
	export default {
		data() {
			return {
				page: 1,
				limit: 20,
				subscribe: [],
				total:0
			}
		},
		onLoad() {
			this.getActiveList()
		},
		onReachBottom() {
			console.log(this.total)
			console.log(this.getActiveList.length)
			if(this.total == this.getActiveList.length ){
				return
			}
			this.page = this.page + 1
			uni.showLoading({
				title: '加载中'
			});
			let time = setTimeout(() => {
				let data = `navActive=${this.page}&limit=${15}&page=${this.page}`
				getActiveList(data).then(res => {
					if (res.data.code == '200') {
						uni.hideLoading()
						this.getActiveList.push(...res.data.data.list)
						this.total = res.data.data.total
					} else {}
				})
				clearTimeout(time)
			}, 1500)
		},
		
		
		methods: {
			getActiveList(type) {
				let data = `navActive=${type}&page=${this.page}&limit=${this.limit}`
				getActiveList(data).then(res => {
					console.log(res)
					if (res.data.code == '200') {
						this.subscribe = res.data.data.list
						this.total = res.data.data.total
					}
				})
			},
			onChange(e) {
				this.active = e.detail.index
				this.getActiveList(this.active)
				getOrderDate().then(res=>{
					console.log(res)
				})
			},
			gotoDetails(order) {
				uni.navigateTo({
					url: '/myIndex/bookingDetails/bookingDetails?order_id='+order
				})

			},
			
		}
	}
</script>

<style lang="scss">
	.contents {
		width: 100%;
		min-height: 100vh;
		background-color: rgb(247, 249, 252);

		.oredr_list {
			width: 694rpx;
			// height: 250rpx;
			background-color: #fff;
			border-radius: 10rpx;
			margin: 35rpx auto 0;

			// display: flex;
			.orderno {
				box-sizing: border-box;
				padding: 26rpx;
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 28rpx;
				border-bottom: 2rpx solid rgb(247, 249, 252);

				.number {
					color: #999;
				}

				.status {
					color: #ED742E;
					font-weight: 600;
				}
			}

			.reservationnumber {
				// box-sizing: border-box;
				padding: 36rpx;
				// width: 100%;
				display: flex;

				.left {
					width: 220rpx;
					height: 140rpx;
					flex-shrink: 0;

					image {
						border-radius: 8rpx;
						width: 100%;
						height: 100%;
					}
				}

				.right {
					width: 360rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					margin-left: 24rpx;

					.eventaddress {
						font-size: 26rpx;
						color: #999;
						display: flex;
						align-items: center;

						image {
							width: 36rpx;
							height: 36rpx;
						}

						text {
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							-o-text-overflow: ellipsis;
						}
					}

					.eventprice {
						display: flex;
						justify-content: space-between;
						align-items: flex-end;

						.price {
							color: #ED742E;
							font-weight: 600;
						}

						.unumber {
							color: #ED742E;
							font-size: 26rpx;
						}
					}
				}
			}
		}
	}
	.zanwudata {
		display: flex;
		justify-content: center;
		margin-top: 30rpx;
		color: #ccc;
		font-size: 28rpx;
	}
</style>
